import {defineStore} from 'pinia'
import {baseName} from '@/utils/constant'
import {getShopCarts} from '@/service/shopcart'

export default defineStore({
  id: `${baseName}-shopcart`,
  state: () => ({
    carts: [],
    cartCount: 0
  }),
  actions: {
    async updateCart() {
      const {data} = await getShopCarts()
      this.cartCount = data.length
    }
  },
  getters: {
    count: state => state.cartCount
  }
})